package com.tarena.lbs.user.exception;

import com.alibaba.nacos.api.remote.response.ErrorResponse;
import com.tarena.lbs.base.protocol.exception.BusinessException;
import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.common.enums.PassportResultEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.validation.ConstraintViolationException;
import java.time.LocalDateTime;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler
    public Result doHandleRuntimeException(RuntimeException ex){
        String data=ex.getMessage();
        log.error("doHandleThrowable:"+data);
        return new Result("1",data,ex);
    }

    @ExceptionHandler
    public Result doHandleThrowable(Throwable ex){
        String data=ex.getMessage();
        log.error("doHandleThrowable:"+data);
        return new Result("1",data,ex);
    }
}
